package com.yowasa.xiuxian.engine.battle.strategy.drop.all;

import com.google.common.collect.Lists;
import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.engine.battle.strategy.BaseBattleStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.BuffContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.entity.enums.InherentTiming;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

@BS(name="非时之梦")
@Order(502)
@Component
public class FeiShiZhiMeng extends BaseBattleStrategy {
    @Autowired
    private BattleHelper battleHelper;

    @Override
    public ElementEnum getElement() {
        return null;
    }
    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {

        int atk = first.getBattleInfo().getAtk();
        int def = second.getBattleInfo().getDef();
        int dmg = battleHelper.calAtk(atk, def) * 2;
        battleHelper.autoAction(this, first, second, content, dmg, "非时之梦");

        BuffContent buff = second.getBuff().get("影寂");
        if (buff == null) {
            BuffContent buffContent = new BuffContent();
            buffContent.setDuration(3);
            buffContent.setNum(1);
            buffContent.setPositive(false);
            second.getBuff().put("影寂", buffContent);
        }else {
            buff.setDuration(3);
            int num=buff.getNum() + 1;
            buff.setNum(num);
        }
        first.getCd().put("非时之梦", 4);
    }

    @Override
    public void limit(UserBO user) {
        throw new HandlerException("该战技无法直接学习，需要拥有 武器-[薙草之稻光] ，装备在身上时自动学会");

    }

    @Override
    public String limitDesc() {
        return "学习/使用非时之梦需要拥有 武器-[薙草之稻光] ";
    }

    @Override
    public boolean check(UserBattleContent user, BattleContent content) {
        Integer cd = user.getCd().get("非时之梦");
        if (cd != null && cd > 0) {
            return false;
        }
        return true;
    }

    @Override
    public String desc() {
        return "稻光，亦是永恒。无想无念，泡影断灭，用于「斩草」的薙刀。对向此物之军势，也会如苇草般倒下吧\n造成物攻2倍的伤害，并为敌方附着[影寂]debuff，持续3回合，对影寂buff的敌人的攻击将无视20%的防御,cd4。";
    }

}
